from django.views.decorators.csrf import csrf_exempt
from rest_framework import generics, permissions, status, viewsets
from rest_framework.response import Response
from rest_framework.parsers import JSONParser

from apps.news.models import KrNews
from apps.news.serializers import KrNewsSerializer




class NewsSetViewSet(viewsets.GenericViewSet):

    model = KrNews
    serializer_class = KrNewsSerializer

    def get_queryset(self):
        return self.model.objects.filter()

    def list(self, request):
        queryset = self.model.objects.all()[:3]
        serializer = self.get_serializer(queryset, many=True)

        return Response(serializer.data, status=status.HTTP_200_OK)


